package com.douwong.student.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.douwong.student.R;
import com.douwong.student.model.ClassExam;

import java.util.List;

public class ClassExamAdapter extends BaseAdapter{

	private Context context;
	private List<ClassExam> list;
	public ClassExamAdapter(Context context, List<ClassExam> list){
		this.context=context;
		this.list=list;
	}
	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Holder holder=null;
		if(convertView==null){
			convertView=LayoutInflater.from(context).inflate(R.layout.class_exam_item, null);
			holder=new Holder();
			holder.title_text=(TextView) convertView.findViewById(R.id.title_text);
			holder.rang_text=(TextView) convertView.findViewById(R.id.range_text);
			holder.totalScore_text=(TextView) convertView.findViewById(R.id.totalScore_text);
			holder.createTime_text=(TextView) convertView.findViewById(R.id.time_text);

			holder.getScore_text=(TextView) convertView.findViewById(R.id.getScore_text);
			convertView.setTag(holder);
		}else {
			holder=(Holder) convertView.getTag();
		}
		if(list.size()>0){
			holder.title_text.setText(list.get(position).getLesLessonExamineexTitle());
			holder.rang_text.setText(list.get(position).getRanking()+"");
			holder.totalScore_text.setText(list.get(position).getLesLessonExamineexScore());
			holder.getScore_text.setText(list.get(position).getExScore());
			holder.createTime_text.setText(list.get(position).getLesLessonExaminecreatetime());
		}
		return convertView;
	}

	class Holder{
		TextView title_text, rang_text,totalScore_text,
		getScore_text,createTime_text;
	}
}
